(function(){"use strict";BX.namespace("BX.Landing.UI.Field");var n=BX.Landing.Utils.isFunction;var t=BX.Landing.Utils.isBoolean;var i=BX.Landing.Utils.clone;var e=BX.Landing.Utils.bind;var o=BX.Landing.Utils.remove;var s=BX.Landing.Utils.escapeHtml;var a=BX.Landing.Utils.fireCustomEvent;BX.Landing.UI.Field.Text=function(i){BX.Landing.UI.Field.BaseField.apply(this,arguments);this.bind=i.bind;this.changeTagButton=i.changeTagButton;this.onInputHandler=n(i.onInput)?i.onInput:function(){};this.onValueChangeHandler=n(i.onValueChange)?i.onValueChange:function(){};this.textOnly=t(i.textOnly)?i.textOnly:false;this.content=this.textOnly?s(this.content):this.content;this.input.innerHTML=this.content;this.onInputClick=this.onInputClick.bind(this);this.onInputMousedown=this.onInputMousedown.bind(this);this.onDocumentMouseup=this.onDocumentMouseup.bind(this);this.onInputInput=this.onInputInput.bind(this);this.onDocumentClick=this.onDocumentClick.bind(this);this.onDocumentKeydown=this.onDocumentKeydown.bind(this);this.onInputKeydown=this.onInputKeydown.bind(this);e(this.input,"click",this.onInputClick);e(this.input,"mousedown",this.onInputMousedown);e(this.input,"input",this.onInputInput);e(this.input,"keydown",this.onInputKeydown);e(document,"click",this.onDocumentClick);e(document,"keydown",this.onDocumentKeydown);e(document,"mouseup",this.onDocumentMouseup)};BX.Landing.UI.Field.Text.prototype={constructor:BX.Landing.UI.Field.Text,__proto__:BX.Landing.UI.Field.BaseField.prototype,onInputInput:function(){this.onInputHandler(this.input.innerText);this.onValueChangeHandler(this);var n=new BX.Event.BaseEvent({data:{value:this.getValue()},compatData:[this.getValue()]});this.emit("change",n)},onDocumentKeydown:function(n){if(n.keyCode===27){if(this.isEditable()){if(this===BX.Landing.UI.Field.BaseField.currentField){BX.Landing.UI.Panel.EditorPanel.getInstance().hide()}this.disableEdit()}}},onInputKeydown:function(n){if(n.keyCode===13){if(this.isTextOnly()){n.preventDefault()}}},enableTextOnly:function(){this.textOnly=true;this.input.innerHTML=BX.util.trim(this.input.innerText)},disableTextOnly:function(){this.textOnly=false},isTextOnly:function(){return this.textOnly},onDocumentClick:function(){if(this.isEditable()&&!this.fromInput){if(this===BX.Landing.UI.Field.BaseField.currentField){BX.Landing.UI.Panel.EditorPanel.getInstance().hide()}this.disableEdit()}this.fromInput=false},onDocumentMouseup:function(){setTimeout(function(){this.fromInput=false}.bind(this),10)},onInputClick:function(n){n.preventDefault();n.stopPropagation();this.fromInput=false},onInputMousedown:function(n){this.enableEdit();BX.Landing.UI.Tool.ColorPicker.hideAll();BX.Landing.UI.Button.FontAction.hideAll();requestAnimationFrame(function(){if(n.target.nodeName==="A"){var t=document.createRange();t.selectNode(n.target);window.getSelection().removeAllRanges();window.getSelection().addRange(t)}});this.fromInput=true;n.stopPropagation()},enableEdit:function(){if(!this.isEditable()){if(this!==BX.Landing.UI.Field.BaseField.currentField&&BX.Landing.UI.Field.BaseField.currentField!==null){BX.Landing.UI.Field.BaseField.currentField.disableEdit()}BX.Landing.UI.Field.BaseField.currentField=this;if(!this.isTextOnly()){if(this.changeTagButton){this.changeTagButton.onChangeHandler=this.onChangeTag.bind(this)}BX.Landing.UI.Panel.EditorPanel.getInstance().show(this.layout,null,this.changeTagButton?[this.changeTagButton]:null);this.input.contentEditable=true}else{BX.Landing.UI.Panel.EditorPanel.getInstance().hide();this.input.contentEditable=true}}},onChangeTag:function(n){this.tag=n},disableEdit:function(){this.input.contentEditable=false},isEditable:function(){return this.input.isContentEditable},reset:function(){this.setValue("")},adjustTags:function(n){if(n.lastChild&&n.lastChild.nodeName==="BR"){o(n.lastChild);this.adjustTags(n)}return n},getValue:function(){return this.adjustTags(i(this.input)).innerHTML}}})();
//# sourceMappingURL=text_field.map.js